<template>
	<view class="container">
		<scroll-view
		:style="'height:'+height+'px;'"
			class="list-scroll-content " 
			scroll-y
			@scrolltolower="getmoneyrecords"
		  
		
		>
		<view style="width: 100%;height: 15px;">

		</view>
		<view class="bill_li" v-if="list.length > 0"  v-for="item in list"
               :key="item.id">
			<view class="">
				<text style="font-size: 16px;">{{ item.desc }}</text></br>
				<text style="font-size: 12px;color: #C0C4CC;">{{ item.created_at }}</text>
			</view>
			<view style="  display: flex; justify-content: center; align-items: center;">
				<text v-if="item.change_type === 'cut'">-</text><text v-else>+</text> </text>{{ item.point }}
			</view>
		</view>
		
		
		<uni-load-more :status="loadingType"></uni-load-more>
		</scroll-view>
	</view>
</template>

<script>
	import uniIcons from '../../ed-icons/ed-icons.vue'
	import { getOne,msg } from '../../api/publicapi.js'
	import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
	export default {
	    components: {
	         uniLoadMore,
			 uniIcons
	    },
		data() {
			return {
				select: ' bill_select',
				selectfles: 'top_item ',
				list: [],
				page: 1,
				height: 0,
				loadingType:'more'
			}
		},
		onLoad (){
		    let that =this
		    uni.getSystemInfo({
		        success: function (res) {
		            //console.log(res)
		            that.height = res.windowHeight
		        }
		    });
		},
		onShow() {
			this.loadingType = 'more'
			this.getmoneyrecords()
		},
		methods: {
			navTo(url) {
				uni.navigateTo({
					url
				})
			},
			getmoneyrecords() {
				console.log( this.loadingType)
				if(this.loadingType === 'loading' || this.loadingType === 'noMore' ){
				    //防止重复加载
				    return;
				}
				this.loadingType = 'loading';
				let data = {
					'page': this.page
				}
				getOne('front/owner/getshoprebate', data).then(res => {

					let list = res.data.data
					if (list.length > 0) {
						this.page += 1
						for (let i = 0; i < list.length; i++) {
							this.list.push(list[i])
						}
						this.loadingType = 'more'
					} else {
						this.loadingType = 'noMore';
						msg(res.data.message)
					}
				})
			}
		}
	}
</script>
<style lang="scss">
	page {
		background: #f7f7f7;
	}

	.bill_top {
		position: fixed;
		top: 0px;
		width: 100%;
		display: flex;
		padding: 10px;
		justify-content: space-between;
		border-bottom: 1px solid #F8F6FC;

		.top_item {
			color: #303133;
			border-bottom: 1px solid #fff;
			padding-right: 10px;
			padding-left: 10px;
			margin-left: 10px;
			margin-right: 10px;
			padding-bottom: 10px;
		}

	}

	.bill_select {
		color: #fa436a;
		border-bottom: 1px solid #fa436a;
		padding-right: 10px;
		padding-left: 10px;
		margin-left: 10px;
		margin-right: 10px;
		padding-bottom: 10px;

	}

	.bill_li {
		display: flex;
		justify-content: space-between;
		border-bottom: 1px solid #C0C4CC;
		background: #fff;
		width: 100%;
		margin: 0 auto;
		padding: 10rpx 20rpx;
	}
	
	.load {
		text-align: center;
		padding: 30upx;
		font-size: 30upx;
	}
</style>
